using UnityEngine;

namespace RGuang.PlathformCtrl
{

    [CreateAssetMenu(menuName = "Data/StateMachine/PlayerState/Land", fileName = "PlayerState_Land")]
    public class PlayerState_Land : PlayerState
    {
        [SerializeField] ParticleSystem landVFX;
        [SerializeField] float stiffTime = 0.2f;//落地硬直时间
        public override void Enter()
        {
            base.Enter();
            player.SetVelocity(Vector3.zero);
            Instantiate(landVFX, player.transform.position, Quaternion.identity);
        }

        public override void LogicUpdate()
        {
            if (player.Victory)
            {
                stateMachine.SwitchState(typeof(PlayerState_Victory));

            }

            if (input.HasJumpInputBuffer|| input.Jump)
            {
                stateMachine.SwitchState(typeof(PlayerState_JumpUp));
            }

            if (stateDuration < stiffTime)
            {
                return;
            }

            if (input.Move)
            {
                stateMachine.SwitchState(typeof(PlayerState_Run));
            }

            if (isAnimationFinished)
            {
                stateMachine.SwitchState(typeof(PlayerState_Idle));
            }


        }

    }

}
